Distributed Tracing in Practice by Ben Sigelman & Jonathan Mace & Daniel Spoonhower & Austin Parker

Distributed Tracing in Practice by Ben Sigelman & Jonathan Mace & Daniel Spoonhower & Austin Parker

Author:Ben Sigelman & Jonathan Mace & Daniel Spoonhower & Austin Parker [Ben Sigelman]
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2019-08-14T16:00:00+00:00


func main() { if len(os.Args) != 3 { panic("ERROR: Expecting two arguments! ftoc/ctof <value>") } tracer := lightstep.NewTracer() defer lightstep.Close() opentracing.SetGlobalTracer(tracer) requestObject := ConversionRequest{ Type := os.Args[1] Value := os.Args[2] } span := tracer.StartSpan("convertValue") span.setTag("operation", requestObject.Type) span.SetTag("initialValue", requestObject.Value) defer span.Finish() ctx := opentracing.ContextWithSpan(context.Background(), span) convertedValue := doConversion(ctx, requestObject) fmt.Println(convertedValue) }

One thing to note here is the usage of the opentracing.ContextWithSpan method. This is a helper function available to us in OpenTracing that adds the given span’s context to a Go context object. If you recall the section on intraprocess propagation, this is a convenient way to propagate context in Go that doesn’t require you to manually pass span contexts around. Indeed, if we look at our doConversion method, you can see how we’re using this -



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.